# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=linphone
pkgver=5.3.38
pkgrel=0
pkgdesc="An opensource SIP phone for voice/video calls and instant messaging"
url="https://linphone.org/"
# riscv64 blocked by java -> belle-sip
arch="all !riscv64"
license="GPL-2.0-or-later"
options="!check" # no test available
# needed for linphonec
depends="belcard"
makedepends="
	bctoolbox-dev
	belcard-dev
	belle-sip-dev
	belr-dev
	cmake
	graphviz-dev
	libnotify-dev
	libxml2-dev
	libxv-dev
	mediastreamer2-dev
	ortp-dev
	readline-dev
	samurai
	speex-dev
	sqlite-dev
	v4l-utils-dev
	xerces-c-dev
	zlib-dev
	zxing-cpp-dev
	"
subpackages="$pkgname-dev $pkgname-libs"
source="https://gitlab.linphone.org/BC/public/liblinphone/-/archive/$pkgver/liblinphone-$pkgver.tar.gz
	fix-cmake-path.patch
	"
builddir="$srcdir/lib$pkgname-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_RPATH=ON \
		-DENABLE_CONSOLE_UI=YES \
		-DENABLE_CXX_WRAPPER=NO \
		-DENABLE_DAEMON=YES \
		-DENABLE_DB_STORAGE=NO \
		-DENABLE_DOC=NO \
		-DENABLE_FLEXIAPI=NO \
		-DENABLE_GTK_UI=NO \
		-DENABLE_LIME=NO \
		-DENABLE_LIME_X3DH=NO \
		-DENABLE_NOTIFY=YES \
		-DBUILD_SHARED_LIBS=YES \
		-DENABLE_STATIC=NO \
		-DENABLE_STRICT=NO \
		-DENABLE_STRICT=NO \
		-DENABLE_TOOLS=YES \
		-DENABLE_UNIT_TESTS=NO \
		-DENABLE_VCARD=YES \
		-DENABLE_VIDEO=YES
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev

	# Fix includes
	sed -i -e 's/INTERFACE_INCLUDE_DIRECTORIES.*/INTERFACE_INCLUDE_DIRECTORIES\  \"\/usr\/include\"/g' "$subpkgdir"/usr/lib/cmake/LibLinphone/LibLinphoneTargets.cmake
}

sha512sums="
3a73cae2665bcc40939000bd7d474551499cfc5a075e49ee6d4afa723c127fa599589e0fabd15de34f28d87529bfe002fa8cdfa4ae42ec31cf734fbeaa862f74  liblinphone-5.3.38.tar.gz
57f3c1ab1172133167991429150e3bbff6213817deea988c302d367a6a0b1315030f2027b6493a64c9b41f3d112d95eeea4a20ae3dc07c3ebb3be3aa95e42d3f  fix-cmake-path.patch
"
